package org.app.original;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class DemoPanel {
	JFrame frame=new JFrame();
	int w=360,h=270;
	public DemoPanel(){
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	//	frame.setSize(360, 270);
		frame.setPreferredSize(new Dimension(w,h));
		frame.setResizable(false);
		frame.setVisible(true);
		
	}
	
	public void show(JPanel panel){
	//	
		frame.setContentPane(panel);
	//	frame.add(panel);
		frame.setPreferredSize(panel.getPreferredSize());
		
		frame.pack();
		System.out.println(panel.getPreferredSize());
		frame.validate();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		DemoPanel panel=new DemoPanel ();
		panel.show();
	}
	
	public JPanel getString(){
		return new JPanel(){

			
			public void paint(Graphics g){
				Graphics2D g2d=(Graphics2D)g;
				g2d.drawString("java", 27,72);
			}
			
			
		};
	}
	
	
	//test
	public void show(){
		this.show(this.getString());
	}

}
